import Vue from 'vue'
import App from './App'
import store from './store'
import {
	utildate
} from './comman/utildate.js';


Vue.config.productionTip = false
Vue.prototype.$store = store
Vue.prototype.utildate = utildate

Vue.prototype.baseURI = 'http://192.168.1.13:3000/';
Vue.prototype.changeDataKey = 'changeData'
Vue.prototype.IsTabBar = (pagePath) => {
	let TabBar = ['/pages/home/index', '/pages/user/user']
	return TabBar.indexOf(pagePath) > -1;
}
Vue.prototype.changeData = () => {
	return uni.getStorageSync(Vue.prototype.changeDataKey)
};
Vue.prototype.removeChangeData = () => {
	uni.removeStorageSync(Vue.prototype.changeDataKey)
};
Vue.prototype.setChangeData = (data) => {
	return uni.setStorageSync(Vue.prototype.changeDataKey, data)
};
Vue.prototype.NoLoginPage = () => {
	var result = new Promise((resolve, reject) => {
		plus.runtime.getProperty(plus.runtime.appid, function(inf) {
			uni.request({
				url: 'http://dl.is.lv-yan.com//version/app/CheckVersion',
				data: {
					appid: plus.runtime.appid,
					systype: plus.os.name == 'Android' ? 0 : 1,
					version: inf.version
				},
				method: 'POST',
				header: {
					'Content-Type': 'application/json'
				},
				success: (res) => {
					resolve(res)
				},
				fail: (res) => {
					resolve(res)
				}
			})
		})
	})
	return result;
}
Vue.prototype.CheckVersion = () => {
	var result = new Promise((resolve, reject) => {
		plus.runtime.getProperty(plus.runtime.appid, function(inf) {
			uni.request({
				url: 'http://dl.is.lv-yan.com//version/app/CheckVersion',
				data: {
					appid: plus.runtime.appid,
					systype: plus.os.name == 'Android' ? 0 : 1,
					version: inf.version
				},
				method: 'POST',
				header: {
					'Content-Type': 'application/json'
				},
				success: (res) => {
					resolve(res)
				},
				fail: (res) => {
					resolve(res)
				}
			})
		})
	})
	return result;
}
Vue.prototype.POST = (url, data) => {

	var result = new Promise((resolve, reject) => {
		uni.request({
			url: Vue.prototype.baseURI + url,
			data: data,
			method: 'POST',
			header: {
				'Content-Type': 'application/json'
			},
			success: (res) => {
				resolve(res)
			},
			fail: (res) => {
				resolve(res)
			}
		})
	})
	return result;
}
Vue.prototype.GET = (url, data) => {
	var result = new Promise((resolve, reject) => {
		uni.request({
			url: Vue.prototype.baseURI + url,
			data: data,
			method: 'GET',
			header: {},
			success: (res) => {
				resolve(res)
			},
			fail: (res) => {
				resolve(res)
			}
		})
	})
	return result;
}

App.mpType = 'app'
const app = new Vue({
	store,
	...App
})
app.$mount()
